<?php
/**
 * Created by PhpStorm.
 * User: 2233
 * Date: 2021/4/3
 * Time: 23:02
 */

namespace app\lib\exception\base;


use think\Exception;

class BaseException extends Exception
{
    protected $code = 404;
    protected $msg = "服务器错误";
    protected $errorCode = "10000";


    /**
     * BaseException constructor.
     * @param array $params 数组 $msg:异常信息 | $code:状态码 | $errorCode:自定义错误码
     */
    public function __construct($params = [])
    {
        if (is_array($params)){
            return ;
        }
        if (array_key_exists('code', $params)){
            $this->setCode($params['code']);
        }
        if (array_key_exists('msg', $params)){
            $this->setMsg($params['msg']);
        }
        if (array_key_exists('errorCode', $params)){
            $this->setErrorCode($params['errorCode']);
        }
    }

    /**
     * @param mixed $code
     */
    public function setCode($code)
    {
        $this->code = $code;
    }

    /**
     * @return mixed
     */
    public function getMsg()
    {
        return $this->msg;
    }

    /**
     * @param mixed $msg
     */
    public function setMsg($msg)
    {
        $this->msg = $msg;
    }

    /**
     * @return mixed
     */
    public function getErrorCode()
    {
        return $this->errorCode;
    }

    /**
     * @param mixed $errorCode
     */
    public function setErrorCode($errorCode)
    {
        $this->errorCode = $errorCode;
    }

}